package org.jeecg.modules.music.model;

import org.jeecg.modules.music.entity.MusCategory;
import org.jeecg.modules.system.model.SysDepartTreeModel;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;

public class MusCategoryTreeModel implements Serializable {
    private static final long serialVersionUID = 1L;

    /** 对应SysDepart中的id字段,前端数据树中的key*/
    private String key;

    /** 对应SysDepart中的id字段,前端数据树中的value*/
    private String value;

    /** 对应depart_name字段,前端数据树中的title*/
    private String title;


    private boolean isLeaf;
    // 以下所有字段均与SysDepart相同

    private String id;

    private String parentId;

    private String categoryName;

    private String logo;

    private String memo;

    private String musCategory;

    private String musType;

    private String musCode;

    private Integer categoryOrder;

    private String status;

    private String delFlag;
    /**创建人*/
    private String createBy;

    private Date createTime;
    /**更新人*/
    private String updateBy;

    private Date updateTime;

    private List<MusCategoryTreeModel> children = new ArrayList<>();

    public MusCategoryTreeModel(){}

    public MusCategoryTreeModel(MusCategory musCategory){
        this.key = musCategory.getId();
        this.value = musCategory.getId();
        this.title = musCategory.getCategoryName();
        this.id = musCategory.getId();
        this.logo = musCategory.getLogo();
        this.parentId = musCategory.getParentId();
        this.categoryName = musCategory.getCategoryName();
        this.categoryOrder = musCategory.getCategoryOrder();
        this.musCategory = musCategory.getMusCategory();
        this.musType = musCategory.getMusType();
        this.musCode = musCategory.getMusCode();
        this.memo = musCategory.getMemo();
        this.status = musCategory.getStatus();
        this.delFlag = musCategory.getDelFlag();
        this.createBy = musCategory.getCreateBy();
        this.createTime = musCategory.getCreateTime();
        this.updateBy = musCategory.getUpdateBy();
        this.updateTime = musCategory.getUpdateTime();
    }

    /**
     * 重写equals方法
     */
    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        MusCategoryTreeModel model = (MusCategoryTreeModel) o;
        return Objects.equals(id, model.id) &&
                Objects.equals(parentId, model.parentId) &&
                Objects.equals(categoryName, model.categoryName) &&
                Objects.equals(categoryOrder, model.categoryOrder) &&
                Objects.equals(musCategory, model.musCategory) &&
                Objects.equals(musType, model.musType) &&
                Objects.equals(musCode, model.musCode) &&
                Objects.equals(memo, model.memo) &&
                Objects.equals(status, model.status) &&
                Objects.equals(logo,model.logo) &&
                Objects.equals(delFlag, model.delFlag) &&
                Objects.equals(createBy, model.createBy) &&
                Objects.equals(createTime, model.createTime) &&
                Objects.equals(updateBy, model.updateBy) &&
                Objects.equals(updateTime, model.updateTime) &&
                Objects.equals(children, model.children);
    }

    /**
     * 重写hashCode方法
     */
    @Override
    public int hashCode() {

        return Objects.hash(id, parentId, categoryName,
                categoryOrder,  musCategory, musType, musCode,
                memo, status, delFlag, logo, createBy, createTime, updateBy, updateTime,
                children);
    }

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public boolean isLeaf() {
        return isLeaf;
    }

    public void setIsLeaf(boolean leaf) {
        isLeaf = leaf;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }

    public String getCategoryName() {
        return categoryName;
    }

    public void setCategoryName(String categoryName) {
        this.categoryName = categoryName;
    }

    public String getLogo() {
        return logo;
    }

    public void setLogo(String logo) {
        this.logo = logo;
    }

    public String getMemo() {
        return memo;
    }

    public void setMemo(String memo) {
        this.memo = memo;
    }

    public String getMusCategory() {
        return musCategory;
    }

    public void setMusCategory(String musCategory) {
        this.musCategory = musCategory;
    }

    public String getMusType() {
        return musType;
    }

    public void setMusType(String musType) {
        this.musType = musType;
    }

    public String getMusCode() {
        return musCode;
    }

    public void setMusCode(String musCode) {
        this.musCode = musCode;
    }

    public Integer getCategoryOrder() {
        return categoryOrder;
    }

    public void setCategoryOrder(Integer categoryOrder) {
        this.categoryOrder = categoryOrder;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getDelFlag() {
        return delFlag;
    }

    public void setDelFlag(String delFlag) {
        this.delFlag = delFlag;
    }

    public String getCreateBy() {
        return createBy;
    }

    public void setCreateBy(String createBy) {
        this.createBy = createBy;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public String getUpdateBy() {
        return updateBy;
    }

    public void setUpdateBy(String updateBy) {
        this.updateBy = updateBy;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }


    public List<MusCategoryTreeModel> getChildren() {
        return children;
    }

    public void setChildren(List<MusCategoryTreeModel> children) {
        if (children==null){
            this.isLeaf=true;
        }
        this.children = children;
    }
}
